package com.authine.cloudpivot.app.openapi.dto.domainmodel;

import com.alibaba.cola.dto.ErrorCodeI;
import org.springframework.http.HttpStatus;

/**
 * @author lifuchun
 */

public enum OpenApiErrorCode implements ErrorCodeI {
    /**
     * 服务对外统一错误码定义
     */
    SERVICE_NOT_OK("SERVICE_NOT_OK", "服务暂不可用", "请找运维小哥哥确认服务已经启动成功"),
    NOT_FOUND(String.valueOf(HttpStatus.NOT_FOUND.value()), "请求的URL不存在", "请检查一下url是否和接口文档中写的一致"),
    UN_AUTHORIZED(String.valueOf(HttpStatus.UNAUTHORIZED.value()), "无操作权限", "请在云枢低代码平台中检查是否对改应用和对应的接口授权"),
    INTERNAL_SERVER_ERROR(String.valueOf(HttpStatus.INTERNAL_SERVER_ERROR.value()), "服务出错了", "请在对应的云枢低代码平台服务端接口排错"),
    ERROR_APP_KEY(String.valueOf(33001), "无效的应用编码", "请确认sdk中配置的appKey是否为对应的云枢低代码平台中已存在的"),
    ERROR_USERID(String.valueOf(33002), "无效的userId", "请检查传递的userId是否已经同步到云枢低代码平台"),
    ERROR_SIGN(String.valueOf(33003), "无效的签名", "请检查sdk中传递appSecret是否是云枢低代码平台派发的"),
    ERROR_TOKEN(String.valueOf(33004), "无效的token", "请重新生成token"),
    SUCCESS(String.valueOf(200), "请求成功", "恭喜"),
    ;


    private final String errCode;
    private final String errDesc;
    private final String correctGuid;

    OpenApiErrorCode(String errCode, String errDesc, String correctGuid) {
        this.errCode = errCode;
        this.errDesc = errDesc;
        this.correctGuid = correctGuid;
    }

    @Override
    public String getErrCode() {
        return errCode;
    }

    @Override
    public String getErrDesc() {
        return errDesc;
    }

    /**
     * 获取微服务的名称
     *
     * @return
     */
    @Override
    public String getServiceName() {
        return "gateway-demo";
    }

    /**
     * 获取恢复错误的正确指导
     *
     * @return
     */
    @Override
    public String getCorrectGuid() {
        return correctGuid;
    }


}
